import requests
import json
import pandas as pd
import re

cookies_list = [
    #  抖音1 的 cookie
    {
    "passport_csrf_token": "29420573e5cd528c09c8ffdfd9d8560d",
    "passport_csrf_token_default": "29420573e5cd528c09c8ffdfd9d8560d",
    "is_staff_user": "false",
    "qc_tt_tag": "0",
    "s_v_web_id": "verify_mh9z984x_QCKP2e97_1mzw_4Cmt_9uRj_OOGQri9Djhqu",
    "gd_random": "eyJtYXRjaCI6dHJ1ZSwicGVyY2VudCI6MC4xODk5MzM2NzE2NTQyMTc2fQ==.HDcVJNGbI84CQzigQ/W7jFgw7OZdY8oUQ8mNZG5z4Jw=",
    "op_session": "ca1b7f04a2552d9ad55fdd30e4085a1e:3a0b9b1071b5adedb32f4f9e12e4622414c2920438fd448283e19d9771037acd",
    "Hm_lvt_b6520b076191ab4b36812da4c90f7a5e": "1762752297,1762909346,1763436056,1763973168",
    "HMACCOUNT": "414D3F5B561355E7",
    "Hm_lpvt_b6520b076191ab4b36812da4c90f7a5e": "1763973171",
    "ttwid": "1%7CCqe9vtPjUd-ToYjUy1mZGjePiF1FmmBDhTdxFk8X76o%7C1763973171%7C0b968a907f72915c8a29bdc2c88e209252250f55ae61cf27ea1a8fe4fbe14285",
    "tt_scid": "WYH3yh.BABnYMFOcA5sdAQWZsICiQcyPHOPUWHAc2Fo38MUc1q-2eNSPYLflzlph326a",
    "passport_mfa_token": "CjchaxUOdowp97qv%2F7hSUnnwvQ8tj%2BP4NMyyAlo4CR7qKFsr5G6DydNnuloCZwKLLlotWc8bgxcCGkoKPAAAAAAAAAAAAABPwJ4yBu9cGTNU2eS0ptN9A5Wlpx4sPVbKpU3u%2BoNh1o6hyMKPnEr8AnG5OmFd0YujHhD2s4IOGPax0WwgAiIBA37E5Dk%3D",
    "odin_tt": "ed22534681c280381d992e21d9e42193eac553dbceaccb6ec16d26053951e1c3e8eb186a6cd6f95348a14b23dea51b8db59b7667811027dd61c14beed280ff56",
    "passport_auth_status": "08e02b5b4ca25cabf2efa447ef0b91d6%2Cfe585f6924d3e2a9506812b60ff585c7",
    "passport_auth_status_ss": "08e02b5b4ca25cabf2efa447ef0b91d6%2Cfe585f6924d3e2a9506812b60ff585c7",
    "uid_tt": "97632583ee356287cf6609602a6cdf74",
    "uid_tt_ss": "97632583ee356287cf6609602a6cdf74",
    "sid_tt": "4b6552e1e73f5cad77634983bfd1a0b4",
    "sessionid": "4b6552e1e73f5cad77634983bfd1a0b4",
    "sessionid_ss": "4b6552e1e73f5cad77634983bfd1a0b4",
    "PHPSESSID": "2153e51f41a763d4341a6f900d4be17c",
    "PHPSESSID_SS": "2153e51f41a763d4341a6f900d4be17c",
    "ucas_c0": "CkEKBTEuMC4wELSIgrSxioaSaRjmJiCuk-Cf3IyABSiwITDsxsCd_63gA0DWsJDJBkjW5MzLBlCavIHI7M3M_2hYbxIUNJnBqaK4rLpr0YG7WTpMTR-ylX8",
    "ucas_c0_ss": "CkEKBTEuMC4wELSIgrSxioaSaRjmJiCuk-Cf3IyABSiwITDsxsCd_63gA0DWsJDJBkjW5MzLBlCavIHI7M3M_2hYbxIUNJnBqaK4rLpr0YG7WTpMTR-ylX8",
    "zsgw_business_data": "%7B%22uuid%22%3A%22ec777450-2d30-4879-961c-4847db11c303%22%2C%22platform%22%3A%22pc%22%2C%22source%22%3A%22seo.fxg.jinritemai.com%22%7D",
    "source": "seo.fxg.jinritemai.com",
    "gfkadpd": "4272,23756",
    "doudain_safety_did": "2579888544967344",
    "csrf_session_id": "a62236e4f6745cccc9e3ea93b810f464",
    "ecom_gray_shop_id": "6496821",
    "sid_guard": "4b6552e1e73f5cad77634983bfd1a0b4%7C1763973214%7C5184000%7CFri%2C+23-Jan-2026+08%3A33%3A34+GMT",
    "sid_ucp_v1": "1.0.0-KGU5MWM5MmU1OWI1YjNkNDc5YTg5N2FhYjc3OGQ2YTQ3ZmY5YjhmYTUKGQjsxsCd_63gAxDesJDJBhiwISAMOAJA8QcaAmxxIiA0YjY1NTJlMWU3M2Y1Y2FkNzc2MzQ5ODNiZmQxYTBiNA",
    "ssid_ucp_v1": "1.0.0-KGU5MWM5MmU1OWI1YjNkNDc5YTg5N2FhYjc3OGQ2YTQ3ZmY5YjhmYTUKGQjsxsCd_63gAxDesJDJBhiwISAMOAJA8QcaAmxxIiA0YjY1NTJlMWU3M2Y1Y2FkNzc2MzQ5ODNiZmQxYTBiNA",
    "session_tlb_tag": "sttt%7C20%7CS2VS4ec_XK13Y0mDv9GgtP_________4WAFqsUZT51NVu5moWUfXGaxL7yI5qT1P0ZMwnMu3YbQ%3D",
    "session_tlb_tag_bk": "sttt%7C20%7CS2VS4ec_XK13Y0mDv9GgtP_________4WAFqsUZT51NVu5moWUfXGaxL7yI5qT1P0ZMwnMu3YbQ%3D",
    "COMPASS_LUOPAN_DT": "session_7576206306727215366",
    "BUYIN_SASID": "SID2_7576206365104537898"
    },
    # 抖音2 的 cookie
    {
        "passport_csrf_token": "29420573e5cd528c09c8ffdfd9d8560d",
        "passport_csrf_token_default": "29420573e5cd528c09c8ffdfd9d8560d",
        "is_staff_user": "false",
        "qc_tt_tag": "0",
        "s_v_web_id": "verify_mh9z984x_QCKP2e97_1mzw_4Cmt_9uRj_OOGQri9Djhqu",
        "gd_random": "eyJtYXRjaCI6dHJ1ZSwicGVyY2VudCI6MC4xODk5MzM2NzE2NTQyMTc2fQ==.HDcVJNGbI84CQzigQ/W7jFgw7OZdY8oUQ8mNZG5z4Jw=",
        "op_session": "ca1b7f04a2552d9ad55fdd30e4085a1e:3a0b9b1071b5adedb32f4f9e12e4622414c2920438fd448283e19d9771037acd",
        "Hm_lvt_b6520b076191ab4b36812da4c90f7a5e": "1762752297,1762909346,1763436056,1763973168",
        "HMACCOUNT": "414D3F5B561355E7",
        "Hm_lpvt_b6520b076191ab4b36812da4c90f7a5e": "1763973171",
        "ttwid": "1%7CCqe9vtPjUd-ToYjUy1mZGjePiF1FmmBDhTdxFk8X76o%7C1763973171%7C0b968a907f72915c8a29bdc2c88e209252250f55ae61cf27ea1a8fe4fbe14285",
        "tt_scid": "WYH3yh.BABnYMFOcA5sdAQWZsICiQcyPHOPUWHAc2Fo38MUc1q-2eNSPYLflzlph326a",
        "passport_mfa_token": "CjchaxUOdowp97qv%2F7hSUnnwvQ8tj%2BP4NMyyAlo4CR7qKFsr5G6DydNnuloCZwKLLlotWc8bgxcCGkoKPAAAAAAAAAAAAABPwJ4yBu9cGTNU2eS0ptN9A5Wlpx4sPVbKpU3u%2BoNh1o6hyMKPnEr8AnG5OmFd0YujHhD2s4IOGPax0WwgAiIBA37E5Dk%3D",
        "odin_tt": "ed22534681c280381d992e21d9e42193eac553dbceaccb6ec16d26053951e1c3e8eb186a6cd6f95348a14b23dea51b8db59b7667811027dd61c14beed280ff56",
        "passport_auth_status": "08e02b5b4ca25cabf2efa447ef0b91d6%2Cfe585f6924d3e2a9506812b60ff585c7",
        "passport_auth_status_ss": "08e02b5b4ca25cabf2efa447ef0b91d6%2Cfe585f6924d3e2a9506812b60ff585c7",
        "uid_tt": "97632583ee356287cf6609602a6cdf74",
        "uid_tt_ss": "97632583ee356287cf6609602a6cdf74",
        "sid_tt": "4b6552e1e73f5cad77634983bfd1a0b4",
        "sessionid": "4b6552e1e73f5cad77634983bfd1a0b4",
        "sessionid_ss": "4b6552e1e73f5cad77634983bfd1a0b4",
        "zsgw_business_data": "%7B%22uuid%22%3A%22ec777450-2d30-4879-961c-4847db11c303%22%2C%22platform%22%3A%22pc%22%2C%22source%22%3A%22seo.fxg.jinritemai.com%22%7D",
        "source": "seo.fxg.jinritemai.com",
        "gfkadpd": "4272,23756",
        "doudain_safety_did": "2579888544967344",
        "csrf_session_id": "a62236e4f6745cccc9e3ea93b810f464",
        "COMPASS_LUOPAN_DT": "session_7576206306727215366",
        "BUYIN_SASID": "SID2_7576206365104537898",
        "ucas_c0": "CkEKBTEuMC4wEKSIkuS3_ImSaRjmJiD3x6C37o3AASiwITDsxsCd_63gA0Dnz5DJBkjng83LBlCzvMvwu7DM_2hYbxIU0aFvhD-e81duYitXEwalSox2pJE",
        "ucas_c0_ss": "CkEKBTEuMC4wEKSIkuS3_ImSaRjmJiD3x6C37o3AASiwITDsxsCd_63gA0Dnz5DJBkjng83LBlCzvMvwu7DM_2hYbxIU0aFvhD-e81duYitXEwalSox2pJE",
        "sid_guard": "4b6552e1e73f5cad77634983bfd1a0b4%7C1763977191%7C5184000%7CFri%2C+23-Jan-2026+09%3A39%3A51+GMT",
        "session_tlb_tag": "sttt%7C20%7CS2VS4ec_XK13Y0mDv9GgtP________--Ca3MgjP9DAopTkdVkcoxIgtW7NxdahkKFWJzVn9Qdp4%3D",
        "session_tlb_tag_bk": "sttt%7C20%7CS2VS4ec_XK13Y0mDv9GgtP________--Ca3MgjP9DAopTkdVkcoxIgtW7NxdahkKFWJzVn9Qdp4%3D",
        "sid_ucp_v1": "1.0.0-KDVkOThkMzc4M2VkNWRiMzE5NTY1ZmI4Y2JmZjMwOTgwMTE4OGQ5YTUKGQjsxsCd_63gAxDnz5DJBhiwISAMOAJA8QcaAmhsIiA0YjY1NTJlMWU3M2Y1Y2FkNzc2MzQ5ODNiZmQxYTBiNA",
        "ssid_ucp_v1": "1.0.0-KDVkOThkMzc4M2VkNWRiMzE5NTY1ZmI4Y2JmZjMwOTgwMTE4OGQ5YTUKGQjsxsCd_63gAxDnz5DJBhiwISAMOAJA8QcaAmhsIiA0YjY1NTJlMWU3M2Y1Y2FkNzc2MzQ5ODNiZmQxYTBiNA",
        "PHPSESSID": "497429f13bb5a2b10a00bac5af21fd13",
        "PHPSESSID_SS": "497429f13bb5a2b10a00bac5af21fd13",
        "ecom_gray_shop_id": "21346083"
    },

    # 抖音3 的 cookie
    {
        "passport_csrf_token": "29420573e5cd528c09c8ffdfd9d8560d",
        "passport_csrf_token_default": "29420573e5cd528c09c8ffdfd9d8560d",
        "is_staff_user": "false",
        "qc_tt_tag": "0",
        "s_v_web_id": "verify_mh9z984x_QCKP2e97_1mzw_4Cmt_9uRj_OOGQri9Djhqu",
        "gd_random": "eyJtYXRjaCI6dHJ1ZSwicGVyY2VudCI6MC4xODk5MzM2NzE2NTQyMTc2fQ==.HDcVJNGbI84CQzigQ/W7jFgw7OZdY8oUQ8mNZG5z4Jw=",
        "op_session": "ca1b7f04a2552d9ad55fdd30e4085a1e:3a0b9b1071b5adedb32f4f9e12e4622414c2920438fd448283e19d9771037acd",
        "Hm_lvt_b6520b076191ab4b36812da4c90f7a5e": "1762752297,1762909346,1763436056,1763973168",
        "HMACCOUNT": "414D3F5B561355E7",
        "Hm_lpvt_b6520b076191ab4b36812da4c90f7a5e": "1763973171",
        "ttwid": "1%7CCqe9vtPjUd-ToYjUy1mZGjePiF1FmmBDhTdxFk8X76o%7C1763973171%7C0b968a907f72915c8a29bdc2c88e209252250f55ae61cf27ea1a8fe4fbe14285",
        "tt_scid": "WYH3yh.BABnYMFOcA5sdAQWZsICiQcyPHOPUWHAc2Fo38MUc1q-2eNSPYLflzlph326a",
        "passport_mfa_token": "CjchaxUOdowp97qv%2F7hSUnnwvQ8tj%2BP4NMyyAlo4CR7qKFsr5G6DydNnuloCZwKLLlotWc8bgxcCGkoKPAAAAAAAAAAAAABPwJ4yBu9cGTNU2eS0ptN9A5Wlpx4sPVbKpU3u%2BoNh1o6hyMKPnEr8AnG5OmFd0YujHhD2s4IOGPax0WwgAiIBA37E5Dk%3D",
        "odin_tt": "ed22534681c280381d992e21d9e42193eac553dbceaccb6ec16d26053951e1c3e8eb186a6cd6f95348a14b23dea51b8db59b7667811027dd61c14beed280ff56",
        "passport_auth_status": "08e02b5b4ca25cabf2efa447ef0b91d6%2Cfe585f6924d3e2a9506812b60ff585c7",
        "passport_auth_status_ss": "08e02b5b4ca25cabf2efa447ef0b91d6%2Cfe585f6924d3e2a9506812b60ff585c7",
        "uid_tt": "97632583ee356287cf6609602a6cdf74",
        "uid_tt_ss": "97632583ee356287cf6609602a6cdf74",
        "sid_tt": "4b6552e1e73f5cad77634983bfd1a0b4",
        "sessionid": "4b6552e1e73f5cad77634983bfd1a0b4",
        "sessionid_ss": "4b6552e1e73f5cad77634983bfd1a0b4",
        "zsgw_business_data": "%7B%22uuid%22%3A%22ec777450-2d30-4879-961c-4847db11c303%22%2C%22platform%22%3A%22pc%22%2C%22source%22%3A%22seo.fxg.jinritemai.com%22%7D",
        "source": "seo.fxg.jinritemai.com",
        "gfkadpd": "4272,23756",
        "doudain_safety_did": "2579888544967344",
        "csrf_session_id": "a62236e4f6745cccc9e3ea93b810f464",
        "COMPASS_LUOPAN_DT": "session_7576206306727215366",
        "BUYIN_SASID": "SID2_7576206365104537898",
        "ucas_c0": "CkEKBTEuMC4wELaIjoCAjIqSaRjmJiDcteCGrcy-AiiwITDsxsCd_63gA0Dl0JDJBkjlhM3LBlCAvOGOoLnM_2hYbxIUVkd9pnhI34h_3RZ2utISHieXdm8",
        "ucas_c0_ss": "CkEKBTEuMC4wELaIjoCAjIqSaRjmJiDcteCGrcy-AiiwITDsxsCd_63gA0Dl0JDJBkjlhM3LBlCAvOGOoLnM_2hYbxIUVkd9pnhI34h_3RZ2utISHieXdm8",
        "sid_guard": "4b6552e1e73f5cad77634983bfd1a0b4%7C1763977317%7C5184000%7CFri%2C+23-Jan-2026+09%3A41%3A57+GMT",
        "session_tlb_tag": "sttt%7C20%7CS2VS4ec_XK13Y0mDv9GgtP_________IkEv2-wy05QjWDiP8dKiLR6uGdTXnmDyKljoXQUFymfo%3D",
        "session_tlb_tag_bk": "sttt%7C20%7CS2VS4ec_XK13Y0mDv9GgtP_________IkEv2-wy05QjWDiP8dKiLR6uGdTXnmDyKljoXQUFymfo%3D",
        "sid_ucp_v1": "1.0.0-KDFhNWJmOWQ3MTA1MWU1ZjlhNGU4MTQ0Mjk4NGUwYTJiYzAzZDc4YzUKGQjsxsCd_63gAxDl0JDJBhiwISAMOAJA8QcaAmhsIiA0YjY1NTJlMWU3M2Y1Y2FkNzc2MzQ5ODNiZmQxYTBiNA",
        "ssid_ucp_v1": "1.0.0-KDFhNWJmOWQ3MTA1MWU1ZjlhNGU4MTQ0Mjk4NGUwYTJiYzAzZDc4YzUKGQjsxsCd_63gAxDl0JDJBhiwISAMOAJA8QcaAmhsIiA0YjY1NTJlMWU3M2Y1Y2FkNzc2MzQ5ODNiZmQxYTBiNA",
        "PHPSESSID": "159bd590d1944316d24d594d985e7e58",
        "PHPSESSID_SS": "159bd590d1944316d24d594d985e7e58",
        "ecom_gray_shop_id": "129811020"
    },
    # 抖音4 的 cookie
    {
        "passport_csrf_token": "29420573e5cd528c09c8ffdfd9d8560d",
        "passport_csrf_token_default": "29420573e5cd528c09c8ffdfd9d8560d",
        "is_staff_user": "false",
        "qc_tt_tag": "0",
        "s_v_web_id": "verify_mh9z984x_QCKP2e97_1mzw_4Cmt_9uRj_OOGQri9Djhqu",
        "gd_random": "eyJtYXRjaCI6dHJ1ZSwicGVyY2VudCI6MC4xODk5MzM2NzE2NTQyMTc2fQ==.HDcVJNGbI84CQzigQ/W7jFgw7OZdY8oUQ8mNZG5z4Jw=",
        "op_session": "ca1b7f04a2552d9ad55fdd30e4085a1e:3a0b9b1071b5adedb32f4f9e12e4622414c2920438fd448283e19d9771037acd",
        "Hm_lvt_b6520b076191ab4b36812da4c90f7a5e": "1762752297,1762909346,1763436056,1763973168",
        "HMACCOUNT": "414D3F5B561355E7",
        "Hm_lpvt_b6520b076191ab4b36812da4c90f7a5e": "1763973171",
        "ttwid": "1%7CCqe9vtPjUd-ToYjUy1mZGjePiF1FmmBDhTdxFk8X76o%7C1763973171%7C0b968a907f72915c8a29bdc2c88e209252250f55ae61cf27ea1a8fe4fbe14285",
        "tt_scid": "WYH3yh.BABnYMFOcA5sdAQWZsICiQcyPHOPUWHAc2Fo38MUc1q-2eNSPYLflzlph326a",
        "passport_mfa_token": "CjchaxUOdowp97qv%2F7hSUnnwvQ8tj%2BP4NMyyAlo4CR7qKFsr5G6DydNnuloCZwKLLlotWc8bgxcCGkoKPAAAAAAAAAAAAABPwJ4yBu9cGTNU2eS0ptN9A5Wlpx4sPVbKpU3u%2BoNh1o6hyMKPnEr8AnG5OmFd0YujHhD2s4IOGPax0WwgAiIBA37E5Dk%3D",
        "odin_tt": "ed22534681c280381d992e21d9e42193eac553dbceaccb6ec16d26053951e1c3e8eb186a6cd6f95348a14b23dea51b8db59b7667811027dd61c14beed280ff56",
        "passport_auth_status": "08e02b5b4ca25cabf2efa447ef0b91d6%2Cfe585f6924d3e2a9506812b60ff585c7",
        "passport_auth_status_ss": "08e02b5b4ca25cabf2efa447ef0b91d6%2Cfe585f6924d3e2a9506812b60ff585c7",
        "uid_tt": "97632583ee356287cf6609602a6cdf74",
        "uid_tt_ss": "97632583ee356287cf6609602a6cdf74",
        "sid_tt": "4b6552e1e73f5cad77634983bfd1a0b4",
        "sessionid": "4b6552e1e73f5cad77634983bfd1a0b4",
        "sessionid_ss": "4b6552e1e73f5cad77634983bfd1a0b4",
        "zsgw_business_data": "%7B%22uuid%22%3A%22ec777450-2d30-4879-961c-4847db11c303%22%2C%22platform%22%3A%22pc%22%2C%22source%22%3A%22seo.fxg.jinritemai.com%22%7D",
        "source": "seo.fxg.jinritemai.com",
        "gfkadpd": "4272,23756",
        "doudain_safety_did": "2579888544967344",
        "csrf_session_id": "a62236e4f6745cccc9e3ea93b810f464",
        "COMPASS_LUOPAN_DT": "session_7576206306727215366",
        "BUYIN_SASID": "SID2_7576206365104537898",
        "ucas_c0": "CkEKBTEuMC4wEJqIi97Tp4qSaRjmJiDkqqC2h8yfAiiwITDsxsCd_63gA0DB0pDJBkjBhs3LBlCbvNyU85fM_2hYbxIUn21bjDdpyxpfUm7Wka7fAZZWpFs",
        "ucas_c0_ss": "CkEKBTEuMC4wEJqIi97Tp4qSaRjmJiDkqqC2h8yfAiiwITDsxsCd_63gA0DB0pDJBkjBhs3LBlCbvNyU85fM_2hYbxIUn21bjDdpyxpfUm7Wka7fAZZWpFs",
        "sid_guard": "4b6552e1e73f5cad77634983bfd1a0b4%7C1763977537%7C5184000%7CFri%2C+23-Jan-2026+09%3A45%3A37+GMT",
        "session_tlb_tag": "sttt%7C3%7CS2VS4ec_XK13Y0mDv9GgtP________-4A67aV-thqSRYhCSUJEKfpeiqHC1s8s4frCTt_OYqdgA%3D",
        "session_tlb_tag_bk": "sttt%7C3%7CS2VS4ec_XK13Y0mDv9GgtP________-4A67aV-thqSRYhCSUJEKfpeiqHC1s8s4frCTt_OYqdgA%3D",
        "sid_ucp_v1": "1.0.0-KDU2ZmI0Yjg5MmJlNjVmMjFiY2E1NzgxNWIwZjIxYzI2ZDIxNThjZDgKGQjsxsCd_63gAxDB0pDJBhiwISAMOAJA8QcaAmxmIiA0YjY1NTJlMWU3M2Y1Y2FkNzc2MzQ5ODNiZmQxYTBiNA",
        "ssid_ucp_v1": "1.0.0-KDU2ZmI0Yjg5MmJlNjVmMjFiY2E1NzgxNWIwZjIxYzI2ZDIxNThjZDgKGQjsxsCd_63gAxDB0pDJBhiwISAMOAJA8QcaAmxmIiA0YjY1NTJlMWU3M2Y1Y2FkNzc2MzQ5ODNiZmQxYTBiNA",
        "PHPSESSID": "f6e5a54953b8bb7186ecf03320b7287e",
        "PHPSESSID_SS": "f6e5a54953b8bb7186ecf03320b7287e",
        "ecom_gray_shop_id": "192389228"
    }
]
shop_name = [
    '宛禾米线官方旗舰店',
    '宛禾食品旗舰店',
    '宛禾官方旗舰店',
    '宛禾米线速食旗舰店'
]



headers = {
    "accept": "application/json, text/plain, */*",
    "accept-language": "zh-CN,zh;q=0.9",
    "content-type": "application/json",
    "origin": "https://fxg.jinritemai.com",
    "priority": "u=1, i",
    "sec-ch-ua": "\"Chromium\";v=\"140\", \"Not=A?Brand\";v=\"24\", \"Google Chrome\";v=\"140\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\"",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "same-origin",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36",
    "x-secsdk-csrf-token": "000100000001ac9abc2a0370214a7746fca256d3ff90edb0ad32c0a563300821d4f2cc09dfa91876e7b9ce989e95"
}
# cookies =.
all_data = []
for i in range(0, len(cookies_list)):
    cookies = cookies_list[i]
    name = shop_name[i]
    url = "https://fxg.jinritemai.com/governance/shop/penalty/get_compensation_list"
    data = {
        "condition": {
            "quick_condition": "all",
            "ticket_create_time_range": {
                "start_time": 1764432000,  # 开始时间   1763913600
                "end_time": 1764518399  # 结束时间   1763999999
            }
        },
        "sort": {
            "sort_type": 1,
            "sort_params": "create_time"
        },
        "page_tab": "compensation_ticket_v2",
        "page": 0,
        "page_size": 50
    }
    data = json.dumps(data, separators=(',', ':'))
    response = requests.post(url, headers=headers, cookies=cookies, data=data)

    body = response.json()
    data = body['data']['tickets']


    for info in data:
        id = info['ticket_id']  # 赔付单id
        object_id = info['object_id']  # 赔付对象订单id
        node_name = info['node_name']  # 赔付原因
        main_status_text = info['status_text_detail']['main_status_text']  # 赔付状态
        standard_appeal_status = info['appeal_info']['standard_appeal_status']  # 赔付状态码  20=待申诉  0=申诉中 1=申诉成功
        biz_show_desc = info['penalty_types_text']  # 赔付金额
        appeal_begin_time = info['appeal_info']['appeal_begin_time']  # 赔付时间
        # json_data = {
        #     "赔付单id": id,
        #     "赔付对象订单id": object_id,
        #     "赔付原因": node_name,
        #     "赔付状态": main_status_text,
        #     "赔付状态码": standard_appeal_status,
        #     "赔付金额": biz_show_desc,
        #     "赔付时间": appeal_begin_time
        # }
        json_data = {
            '店铺': name,
            '赔付原因': node_name,
            '赔付金额': biz_show_desc,

        }

        # ✅ 关键修改2：添加到列表
        all_data.append(json_data)
        print(json_data)


# 数据处理
df = pd.DataFrame(all_data)

# 店铺映射（根据实际情况调整）
shop_mapping = {
    '宛禾米线官方旗舰店': '抖音1',
    '宛禾食品旗舰店': '抖音2',
    '宛禾官方旗舰店': '抖音3',
    '宛禾米线速食旗舰店': '抖音4'
}


# 提取金额数值
def extract_amount(text):
    match = re.search(r'(\d+\.?\d*)', str(text))
    return float(match.group(1)) if match else 0.0


df['赔付金额_数值'] = df['赔付金额'].apply(extract_amount)
df['店铺'] = df['店铺'].map(shop_mapping).fillna(df['店铺'])

#  只保留3列：店铺、赔付原因、赔付金额
result = df.groupby(['店铺', '赔付原因'], as_index=False)['赔付金额_数值'].sum()
result.columns = ['店铺', '赔付原因', '赔付金额']

# 按店铺和金额排序
result = result.sort_values(['店铺', '赔付金额'], ascending=[True, False])

# 显示结果
print("=== 赔付汇总（按店铺和原因）===")
print(result.to_string(index=False))

# 导出Excel
result.to_excel(r'G:\结果\抖音赔付汇总.xlsx', index=False)
print("\n✅ 已导出到: 抖音赔付汇总.xlsx")




# https://tool.lu/timestamp/
# https://spidertools.cn/#/curl2Request


# 操作手册
# 1.打开赔付列表 按F12
# 2.按ctrl+r 刷新页面
# 3.复制第一个订单号 搜索
# 4.搜索结果看 get_compensation_list 这个接口
# 5.放到接口按鼠标右键 有复制  以curl(bush)格式复制
# 6.https://spidertools.cn/#/curl2Request  打开上面的网址 选curl转requests
# 7.把复制的curl(bush)格式粘贴进去
# 8.把转换后的cookies粘贴到代码里   三天更换一次

